<template>
    <div>
        <div>
            <van-nav-bar
                    title="个人详情"
                    left-text="返回"
                    left-arrow
                    @click-left="onClickLeft"
            />
        </div>
        <div class="headimg" style="margin-top: 30px">
            <p><span style="float: left;margin-left: 18px;line-height: 50px">头像</span>
                <van-image style="float: right;margin-right: 30px;margin-top: 3px" @click="changeImg"
                           round
                           width="3rem"
                           height="3rem"
                           src="https://img01.yzcdn.cn/vant/cat.jpeg"
                />
            </p>
            <div style="float: none">
                <van-cell-groupn>
                    <van-field v-model="nickname" label="昵称" placeholder="请输入昵称"/>
                    <van-field v-model="sex" label="性别" placeholder="请输入性别"/>
                    <van-field v-model="address" label="地址" placeholder="请输入地址"/>
                </van-cell-groupn>
            </div>
            <van-button style="margin-top: 30px" plain hairline type="info" @click="saveInfo">
                确定
            </van-button>
        </div>
    </div>


</template>

<script>
    import {Toast} from 'vant';
    import {reactive} from 'vue';

    export default {
        name: "MyForm",
        data() {
            return {
                nickname: '',
                sex: '',
                ctime: '',
                address: '',
            };
        },
        setup() {
            const onClickLeft = () => Toast('返回');
            return {
                onClickLeft
            };
        },
        methods: {
            onClickLeft() {
                this.$router.push("/Set")
            },
            changeImg() {
                //修改头像
                this.$toast("点击了修改头像")
            }, saveInfo() {
                //保存信息
                this.$toast("点击了保存信息")
                var that = this;
                console.log(this.loginForm)
                this.axios.post('http://localhost:8080/api/userinfo/save.do',
                    "nickname="+this.nickname+"&sex="+this.sex +"&address="+this.address
                ).then(function (res) {
                    if (res.data.code == 10000) {
                        let path = that.$route.query.redirect
                        that.$router.replace(path == '/' || path == undefined ? '/My' : path)
                    } else {
                        that.$toast("登陆失败")
                    }
                })
            }

        },
    }
</script>

<style scoped>
</style>